home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / portfoli / bootst11.lzh / PF BOOTSTRAP VAXMODEM XMODEMH < prev   
Text File  |  1991-05-03  |  4KB  |  103 lines

  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/time.h>
  6. #include <sgtty.h>
  7. #include <signal.h>
  8.  
  9. /* define macros to print messages in log file */
  10. #define  logit(string) if(LOGFLAG)fprintf(LOGFP,string)
  11. #define  logitarg(string,argument) if(LOGFLAG)fprintf(LOGFP,string,argument)
  12. #define  tlogit(string) if(TIPFLAG)fprintf(stderr,string)
  13. #define  tlogitarg(string,argument) if(TIPFLAG)fprintf(stderr,string,argument)
  14.  
  15. #define         VERSION    "3.9 (November 1990)"
  16. #define      FALSE      0
  17. #define      TRUE       1
  18.  
  19.  
  20. /*  ASCII Constants  */
  21. #define      SOH      001 
  22. #define         STX    002
  23. #define         ETX    003
  24. #define      EOT    004
  25. #define         ENQ    005
  26. #define      ACK      006
  27. #define         LF        012   /* Unix LF/NL */
  28. #define         CR        015  
  29. #define      NAK      025
  30. #define         SYN    026
  31. #define         CAN    030
  32. #define         ESC    033
  33.  
  34. /*  XMODEM Constants  */
  35. #define      TIMEOUT      -1
  36. #define      ERRORMAX      10    /* maximum errors tolerated while transferring a packet */
  37. #define      WAITFIRST  1     /* seconds between startup characters in read */
  38. #define      STERRORMAX    60    /* maximum "errors" tolerated in read startup */
  39. #define      CRCSWMAX    30    /* maximum time to try CRC mode before switching */
  40. #define      NAKMAX    120   /* maximum times to wait for initial NAK when sending */
  41. #define      RETRYMAX      5     /* maximum retries to be made certain handshaking routines */
  42. #define      KSWMAX    5     /* maximum errors before switching to 128 byte packets */
  43. #define      EOTMAX    10    /* maximum times sender will send an EOT to end transfer */
  44. #define      SLEEPNUM    100   /* target number of characters to collect during sleepy time */
  45. #define         BBUFSIZ    1024  /* buffer size */
  46. #define      NAMSIZ    11    /* length of a CP/M file name string */
  47. #define         CTRLZ    032   /* CP/M EOF for text (usually!) */
  48. #define      CRCCHR    'C'   /* CRC request character */
  49. #define      KCHR    'K'   /* 1K block request character */
  50. #define      GCHR    'G'   /* Ymodem-G request character */
  51. #define      BAD_NAME    'u'   /* Bad filename indicator */
  52. #define      TIPDELAY    15    /* seconds to delay handshake startup when -w */
  53.  
  54. #define      CREATMODE    0644  /* mode for created files */
  55.  
  56. /* GLOBAL VARIABLES */
  57.  
  58. int ttyspeed;        /* tty speed (bits per second) */
  59. unsigned char buff[BBUFSIZ];    /* buffer for data */
  60. int nbchr;        /* number of chars read so far for buffered read */
  61. long filelength;    /* length specified in YMODEM header */
  62. long fileread;        /* characters actually read so far in file */
  63. char filename[256];    /* place to construct filenames */
  64. int yfilesleft;        /* # of files left for YMODEM header */
  65. long ytotleft;        /* # of bytes left for YMODEM header */
  66.  
  67. FILE *LOGFP;        /* descriptor for LOG file */
  68.  
  69. /* option flags and state variables */
  70. char    XMITTYPE;    /* text or binary? */
  71. int    DEBUG;        /* keep debugging info in log? */
  72. int    RECVFLAG;    /* receive? */
  73. int    SENDFLAG;    /* send? */
  74. int    BATCH;        /* batch? (Now used as a state variable) */
  75. int    CRCMODE;    /* CRC or checksums? */
  76. int    DELFLAG;    /* don't delete old log file? */
  77. int    LOGFLAG;    /* keep log? */
  78. int    LONGPACK;     /* do not use long packets on transmit? */
  79. int    MDM7BAT;    /* MODEM7 batch protocol */
  80. int    YMDMBAT;    /* YMODEM batch protocol */
  81. int    TOOBUSY;    /* turn off sleeping in packet read routine */
  82. int    TIPFLAG;    /* for tip ~C command */
  83. int    DELAYFLAG;    /* for startup delay */
  84. int    NOEOT;        /* suppress EOT verification */
  85. int    CANCAN;        /* allow CAN-CAN aborts anytime */
  86. int    YMODEMG;    /* YMODEM-G variant of YMODEM */
  87.  
  88. int    CHECKLENGTH;    /* Are we truncating a file to a YMODEM length? */
  89.  
  90.  
  91. /*   CRC-16 constants.  From Usenet contribution by Mark G. Mendel, 
  92.      Network Systems Corp.  (ihnp4!umn-cs!hyper!mark)
  93. */
  94.  
  95.     /* the CRC polynomial. */
  96. #define    P    0x1021
  97.  
  98.     /* number of bits in CRC */
  99. #define W    16
  100.  
  101.     /* the number of bits per char */
  102. #define B    8
  103.